﻿@model IEnumerable<ECatalog.Models.Organization>
<div class="container">
    <div class="row">
        <p>
            @Html.ActionLink("Добавить организацию", "Create", null, new { @class = "btn btn-primary" })
        </p>
        <table class="table table-bordered table-hover">
            <tr>
                <th>Название
                </th>
                <th>Логотип</th>
                <th>Описание
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                         @{
                            var imageUrl = "";
                            if (Model != null)
                            {
                                imageUrl = string.Format("/Files/Organization-{0}/Logo-{1}/320x240/{2}{3}", @item.OrganizationId, @item.LogoUrl, @item.LogoUrl,@item.TypeImage);
                            }
                        }
                        <img class="photo-block" src="@imageUrl" alt="" />
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    <td>
                        @Html.ActionLink("Редактировать", "Edit", new { id = item.OrganizationId })
                        @using (Html.BeginForm("Delete", "Organization", new { id = item.OrganizationId }))
                        {
                            <input type="submit" value="Удалить" class="btn btn-link" />
                        }
                    </td>
                </tr>
            }

        </table>
    </div>
</div>
